import logging

from selenium.webdriver.common.by import By

from utils.base_aolai import BaseObject


class HomeObject(BaseObject):
    def __init__(self):
        super().__init__()
        self.alert = (By.ID, 'com.yunmall.lc:id/img_close')
        self.my_btn = (By.ID, 'com.yunmall.lc:id/tab_me')

    def findAlert(self):
        return self.search_ele(self.alert)

    def findMy_btn(self):
        return self.search_ele(self.my_btn)


class HomeHandle:
    def __init__(self):
        self.ho = HomeObject()

    def alertClose(self):
        logging.info("关闭更新弹窗")
        self.ho.findAlert().click()

    def gotoMy_btu(self):
        logging.info("点击我的")
        self.ho.findMy_btn().click()


class HomeTask:
    logging.info("首页")
    hh = HomeHandle()
    @classmethod
    def close_alert(cls):
        cls.hh.alertClose()

    @classmethod
    def intoMy_btu(cls):
        cls.hh.gotoMy_btu()
